package com.wss.module.main.ui.page;

import com.orhanobut.logger.Logger;
import com.wss.common.base.BaseActionBarAbility;
import com.wss.common.base.mvp.BasePresenter;
import com.wss.module.main.ResourceTable;
import com.wss.module.main.ui.view.ca.SenseCamera;
import com.wss.module.main.ui.view.ca.SenseCameraPreview;
import ohos.aafwk.content.Intent;
import ohos.agp.components.StackLayout;
import ohos.agp.components.surfaceprovider.SurfaceProvider;
import ohos.agp.graphics.SurfaceOps;

import java.io.IOException;

public class MarqueeAbility extends BaseActionBarAbility {

    private SenseCameraPreview mCameraPreview;

    protected SenseCamera mCamera;
    protected static final int DEFAULT_PREVIEW_WIDTH = 1920;
    protected static final int DEFAULT_PREVIEW_HEIGHT = 1080;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        getWindow().setTransparent(true);
        initView();
    }

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_marquee;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    private void initView() {
        mCameraPreview = (SenseCameraPreview) findComponentById(ResourceTable.Id_save_non_transition_alpha);

        mCameraPreview.setStartListener(new SenseCameraPreview.StartListener() {
            @Override
            public void onFail() {
                Logger.e("setStartListener  onFail");
            }
        });
        mCamera = new SenseCamera.Builder(this)
                .setRequestedPreviewSize(DEFAULT_PREVIEW_WIDTH, DEFAULT_PREVIEW_HEIGHT)
                .build();
    }

    private SurfaceProvider mSurfaceView;

    @Override
    protected void onActive() {
        super.onActive();
        try {
            System.out.println("==== marquee ability on active....");
            this.mCameraPreview.start(this.mCamera);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
